package com.spring.xenon.web.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.spring.security.core.util.ApplicationUtils;
import com.spring.security.core.util.UpdateMap;
import com.spring.security.web.dao.CommonMapper;
import com.spring.xenon.web.dao.MenuMapper;
import com.spring.xenon.web.model.Menu;
import com.spring.xenon.web.service.MenuService;
import com.spring.xenon.web.tools.MenuMaker;

@Service
public class MenuServiceImpl implements MenuService{
    @Resource
    private MenuMapper menuMapper;
    
    @Resource
	private CommonMapper commonMapper;

	@Override
	public String createMenu(String id) {
		List<Menu> m = menuMapper.getMenu(id);
		String menuHtml = MenuMaker.createMenu(m);
		return menuHtml;
	}
	
	@Override
	public List<Menu> getMenu(String id) {
		List<Menu> m = menuMapper.getMenu(id);
		return m;
	}
	
	@Override
	public Map<String, Object> getDataList() {
		// TODO Auto-generated method stub
		Map<String, Object> m = new HashMap<String, Object>();
		try {

			UpdateMap sel = new UpdateMap("c_user");
			sel.addWhere("1", "1");
			List<Map<String,Object>> list = commonMapper.select(sel);
			m.put("data", list);

		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();
		}
		return m;
	}
	

}
